<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
  <meta name="theme-color" content="#222">
  <meta name="generator" content="Hexo 5.4.0">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

  <link rel="stylesheet" href="/css/main.css">



  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.2/css/all.min.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.1.1/animate.min.css">

  <script class="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {
      "hostname": "holidaypenguin.gitee.io",
      "root": "/",
      "images": "/images",
      "scheme": "Mist",
      "version": "8.2.2",
      "exturl": false,
      "sidebar": {
        "position": "right",
        "display": "always",
        "padding": 18,
        "offset": 12
      },
      "copycode": true,
      "bookmark": {
        "enable": false,
        "color": "#222",
        "save": "auto"
      },
      "fancybox": false,
      "mediumzoom": false,
      "lazyload": false,
      "pangu": false,
      "comments": {
        "style": "tabs",
        "active": null,
        "storage": true,
        "lazyload": false,
        "nav": null
      },
      "motion": {
        "enable": true,
        "async": true,
        "transition": {
          "post_block": "fadeIn",
          "post_header": "fadeInDown",
          "post_body": "fadeInDown",
          "coll_header": "fadeInLeft",
          "sidebar": "slideUpIn"
        }
      },
      "prism": false,
      "i18n": {
        "placeholder": "搜索...",
        "empty": "没有找到任何搜索结果：${query}",
        "hits_time": "找到 ${hits} 个搜索结果（用时 ${time} 毫秒）",
        "hits": "找到 ${hits} 个搜索结果"
      },
      "path": "/search.xml",
      "localsearch": {
        "enable": true,
        "trigger": "auto",
        "top_n_per_article": 1,
        "unescape": false,
        "preload": false
      }
    };
  </script>
  <meta property="og:type" content="article">
  <meta property="og:title" content="JavsScript ES10&amp;ES2019的新特性">
  <meta property="og:url" content="https://holidaypenguin.gitee.io/blob/2019-04-17-new-features-of-javsscript-es10-&-es2019/index.html">
  <meta property="og:site_name" content="HolidayPenguin">
  <meta property="og:locale" content="zh_CN">
  <meta property="og:image" content="https://holidaypenguin.gitee.io/images/es/0001.webp">
  <meta property="og:image" content="https://holidaypenguin.gitee.io/images/es/0003.png">
  <meta property="og:image" content="https://holidaypenguin.gitee.io/images/es/0004.png">
  <meta property="og:image" content="https://holidaypenguin.gitee.io/images/es/0005.png">
  <meta property="og:image" content="https://holidaypenguin.gitee.io/images/es/0006.png">
  <meta property="og:image" content="https://holidaypenguin.gitee.io/images/es/0007.png">
  <meta property="article:published_time" content="2019-04-17T12:37:13.000Z">
  <meta property="article:modified_time" content="2019-04-17T12:37:13.000Z">
  <meta property="article:author" content="holidaypenguin">
  <meta property="article:tag" content="JavaScript">
  <meta property="article:tag" content="Ecma">
  <meta property="article:tag" content="ECMAScript">
  <meta property="article:tag" content="ES10">
  <meta property="article:tag" content="ES2019">
  <meta property="article:tag" content="ECMAScript 2019">
  <meta name="twitter:card" content="summary">
  <meta name="twitter:image" content="https://holidaypenguin.gitee.io/images/es/0001.webp">


  <link rel="canonical" href="https://holidaypenguin.gitee.io/blob/2019-04-17-new-features-of-javsscript-es10-&-es2019/">


  <script class="page-configurations">
    // https://hexo.io/docs/variables.html
    CONFIG.page = {
      sidebar: "",
      isHome: false,
      isPost: true,
      lang: 'zh-CN'
    };
  </script>
  <title>JavsScript ES10&ES2019的新特性 | HolidayPenguin</title>





  <noscript>
    <style>
      body {
        margin-top: 2rem;
      }

      .use-motion .menu-item,
      .use-motion .sidebar,
      .use-motion .post-block,
      .use-motion .pagination,
      .use-motion .comments,
      .use-motion .post-header,
      .use-motion .post-body,
      .use-motion .collection-header {
        visibility: visible;
      }

      .use-motion .header,
      .use-motion .site-brand-container .toggle,
      .use-motion .footer {
        opacity: initial;
      }

      .use-motion .site-title,
      .use-motion .site-subtitle,
      .use-motion .custom-logo-image {
        opacity: initial;
        top: initial;
      }

      .use-motion .logo-line {
        transform: scaleX(1);
      }

      .search-pop-overlay,
      .sidebar-nav {
        display: none;
      }

      .sidebar-panel {
        display: block;
      }
    </style>
  </noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner">
        <div class="site-brand-container">
          <div class="site-nav-toggle">
            <div class="toggle" aria-label="切换导航栏" role="button">
              <span class="toggle-line"></span>
              <span class="toggle-line"></span>
              <span class="toggle-line"></span>
            </div>
          </div>

          <div class="site-meta">

            <a href="/" class="brand" rel="start">
              <i class="logo-line"></i>
              <h1 class="site-title">HolidayPenguin</h1>
              <i class="logo-line"></i>
            </a>
          </div>

          <div class="site-nav-right">
            <div class="toggle popup-trigger">
              <i class="fa fa-search fa-fw fa-lg"></i>
            </div>
          </div>
        </div>



        <nav class="site-nav">
          <ul class="main-menu menu">
            <li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a></li>
            <li class="menu-item menu-item-tags"><a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a></li>
            <li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a></li>
            <li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a></li>
            <li class="menu-item menu-item-search">
              <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
              </a>
            </li>
          </ul>
        </nav>



        <div class="search-pop-overlay">
          <div class="popup search-popup">
            <div class="search-header">
              <span class="search-icon">
                <i class="fa fa-search"></i>
              </span>
              <div class="search-input-container">
                <input autocomplete="off" autocapitalize="off" maxlength="80" placeholder="搜索..." spellcheck="false" type="search" class="search-input">
              </div>
              <span class="popup-btn-close" role="button">
                <i class="fa fa-times-circle"></i>
              </span>
            </div>
            <div class="search-result-container no-result">
              <div class="search-result-icon">
                <i class="fa fa-spinner fa-pulse fa-5x"></i>
              </div>
            </div>

          </div>
        </div>

      </div>


      <div class="toggle sidebar-toggle" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
      </div>

      <aside class="sidebar">

        <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
          <ul class="sidebar-nav">
            <li class="sidebar-nav-toc">
              文章目录
            </li>
            <li class="sidebar-nav-overview">
              站点概览
            </li>
          </ul>

          <div class="sidebar-panel-container">
            <!--noindex-->
            <div class="post-toc-wrap sidebar-panel">
              <div class="post-toc animated">
                <ol class="nav">
                  <li class="nav-item nav-level-2"><a class="nav-link" href="#Array-flat"><span class="nav-number">1.</span> <span class="nav-text">Array.flat()</span></a></li>
                  <li class="nav-item nav-level-2"><a class="nav-link" href="#Array-flatMap"><span class="nav-number">2.</span> <span class="nav-text">Array.flatMap()</span></a></li>
                  <li class="nav-item nav-level-2"><a class="nav-link" href="#Object-fromEntries"><span class="nav-number">3.</span> <span class="nav-text">Object.fromEntries()</span></a></li>
                  <li class="nav-item nav-level-2"><a class="nav-link" href="#String-trimStart-amp-String-trimEnd"><span class="nav-number">4.</span> <span class="nav-text">String.trimStart() &amp; String.trimEnd()</span></a></li>
                  <li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%A0%BC%E5%BC%8F%E8%89%AF%E5%A5%BD%E7%9A%84JSON-stringify"><span class="nav-number">5.</span> <span class="nav-text">格式良好的JSON.stringify()</span></a></li>
                  <li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%A8%B3%E5%AE%9A%E7%9A%84Array-prototype-sort"><span class="nav-number">6.</span> <span class="nav-text">稳定的Array.prototype.sort()</span></a></li>
                  <li class="nav-item nav-level-2"><a class="nav-link" href="#New-Function-toString"><span class="nav-number">7.</span> <span class="nav-text">New Function.toString()</span></a></li>
                  <li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%8F%AF%E9%80%89%E7%9A%84Catch-Binding"><span class="nav-number">8.</span> <span class="nav-text">可选的Catch Binding</span></a>
                    <ol class="nav-child">
                      <li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%9C%A8ES10%E4%B8%AD%EF%BC%8CCatch-Error-Binding%E6%98%AF%E5%8F%AF%E9%80%89%E7%9A%84"><span class="nav-number">8.1.</span> <span class="nav-text">在ES10中，Catch Error Binding是可选的</span></a></li>
                    </ol>
                  </li>
                  <li class="nav-item nav-level-2"><a class="nav-link" href="#Symbol-description"><span class="nav-number">9.</span> <span class="nav-text">Symbol.description</span></a></li>
                  <li class="nav-item nav-level-2"><a class="nav-link" href="#Hashbang-%E8%AF%AD%E6%B3%95"><span class="nav-number">10.</span> <span class="nav-text">Hashbang 语法</span></a></li>
                  <li class="nav-item nav-level-2"><a class="nav-link" href="#ES10-Classes-private-static-amp-public-members"><span class="nav-number">11.</span> <span class="nav-text">ES10 Classes: private, static &amp; public members</span></a></li>
                  <li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%80%BB%E7%BB%93%E4%B8%8E%E5%8F%8D%E9%A6%88"><span class="nav-number">12.</span> <span class="nav-text">总结与反馈</span></a></li>
                </ol>
                </li>
                <li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%8F%82%E8%80%83"><span class="nav-number"></span> <span class="nav-text">参考</span></a>
              </div>
            </div>
            <!--/noindex-->

            <div class="site-overview-wrap sidebar-panel">
              <div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
                <p class="site-author-name" itemprop="name">holidaypenguin</p>
                <div class="site-description" itemprop="description"></div>
              </div>
              <div class="site-state-wrap site-overview-item animated">
                <nav class="site-state">
                  <div class="site-state-item site-state-posts">
                    <a href="/archives/">

                      <span class="site-state-item-count">138</span>
                      <span class="site-state-item-name">日志</span>
                    </a>
                  </div>
                  <div class="site-state-item site-state-categories">
                    <a href="/categories/">

                      <span class="site-state-item-count">26</span>
                      <span class="site-state-item-name">分类</span></a>
                  </div>
                  <div class="site-state-item site-state-tags">
                    <a href="/tags/">

                      <span class="site-state-item-count">234</span>
                      <span class="site-state-item-name">标签</span></a>
                  </div>
                </nav>
              </div>
              <div class="links-of-author site-overview-item animated">
                <span class="links-of-author-item">
                  <a href="https://github.com/holidaypenguin" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;holidaypenguin" rel="noopener" target="_blank"><i class="github fa-fw"></i>GitHub</a>
                </span>
                <span class="links-of-author-item">
                  <a href="mailto:songshipeng2016@gmail.com" title="E-Mail → mailto:songshipeng2016@gmail.com" rel="noopener" target="_blank"><i class="envelope fa-fw"></i>E-Mail</a>
                </span>
              </div>



            </div>
          </div>
        </div>
      </aside>
      <div class="sidebar-dimmer"></div>


    </header>


    <div class="back-to-top" role="button">
      <i class="fa fa-arrow-up"></i>
      <span>0%</span>
    </div>

    <noscript>
      <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
    </noscript>


    <div class="main-inner post posts-expand">





      <div class="post-block">



        <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
          <link itemprop="mainEntityOfPage" href="https://holidaypenguin.gitee.io/blob/2019-04-17-new-features-of-javsscript-es10-&-es2019/">

          <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
            <meta itemprop="image" content="/images/avatar.gif">
            <meta itemprop="name" content="holidaypenguin">
            <meta itemprop="description" content="">
          </span>

          <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
            <meta itemprop="name" content="HolidayPenguin">
          </span>
          <header class="post-header">
            <h1 class="post-title" itemprop="name headline">
              JavsScript ES10&ES2019的新特性
            </h1>

            <div class="post-meta-container">
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>

                  <time title="创建时间：2019-04-17 20:37:13" itemprop="dateCreated datePublished" datetime="2019-04-17T20:37:13+08:00">2019-04-17</time>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-folder"></i>
                  </span>
                  <span class="post-meta-item-text">分类于</span>
                  <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                    <a href="/categories/JavaScript/" itemprop="url" rel="index"><span itemprop="name">JavaScript</span></a>
                  </span>
                </span>


                <span id="/blob/2019-04-17-new-features-of-javsscript-es10-&-es2019/" class="post-meta-item leancloud_visitors" data-flag-title="JavsScript ES10&ES2019的新特性" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
              </div>

              <div class="post-description">
                <!-- more -->
              </div>
            </div>
          </header>




          <div class="post-body" itemprop="articleBody">
            <p>本文系转载</p>
            <p>写在前面的话标准非实际情况。</p>
            <p>ECMAScript 2019，ECMA-262 标准版本的第19版（通常称为ES2019或ES10），于 2019 年 6 月完成。</p>
            <blockquote>
              <p>This specification, the 10th edition, introduces a few new built-in functions: <code>flat</code> and <code>flatMap</code> on <code>Array.prototype</code> for flattening arrays, <code>Object.fromEntries</code> for directly turning the return value of <code>Object.entries</code> into a new Object, and <code>trimStart</code> and <code>trimEnd</code> on <code>String.prototype</code> as better-named alternatives to the widely implemented but non-standard <code>String.prototype.trimLeft</code> and <code>trimRight</code> built-ins. In addition, this specification includes a few minor updates to syntax and semantics. Updated syntax includes optional catch binding parameters and allowing U+2028 (LINE SEPARATOR) and U+2029 (PARAGRAPH SEPARATOR) in string literals to align with JSON. Other updates include requiring that <code>Array.prototype.sort</code> be a stable sort, requiring that JSON.stringify return well-formed UTF-8 regardless of input, and clarifying <code>Function.prototype.toString</code> by requiring that it either return the corresponding original source text or a standard placeholder.</p>
            </blockquote>
            <p><code>ES10</code>中除了 <code>Object.fromEntries</code>大多数功能已经在 <code>Chrome</code>中实现，所以你为什么不尽早开始探索它呢？当所有浏览器开始支持它时，你已经获得了领先优势，这只是时间问题。对于有兴趣探索ES10的人来说，这是一份 <strong>非外星人</strong>指南。</p>
            <p><strong>ES10在新语言功能方面没有ES6那么重要，但它确实添加了一些有趣的东西（其中一些在目前版本的浏览器中还不起作用：02/20/2019）</strong></p>
            <p><img src="" data-original="/images/es/0001.webp" alt="0001"></p>
            <p><code>ES6</code>中最受欢迎的功能莫过于箭头函数了，那么 <code>ES10</code>中呢?</p>
            <h2 id="Array-flat"><a href="#Array-flat" class="headerlink" title="Array.flat()"></a>Array.flat()</h2>
            <p>扁平化多维数组：</p>
            <figure class="highlight js">
              <table>
                <tr>
                  <td class="gutter">
                    <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre>
                  </td>
                  <td class="code">
                    <pre><span class="line"><span class="keyword">let</span> multi = [<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>,[<span class="number">4</span>,<span class="number">5</span>,<span class="number">6</span>,[<span class="number">7</span>,<span class="number">8</span>,<span class="number">9</span>,[<span class="number">10</span>,<span class="number">11</span>,<span class="number">12</span>]]]];</span><br><span class="line">multi.flat();               <span class="comment">// [1,2,3,4,5,6,Array(4)]</span></span><br><span class="line">multi.flat().flat();        <span class="comment">// [1,2,3,4,5,6,7,8,9,Array(3)]</span></span><br><span class="line">multi.flat().flat().flat(); <span class="comment">// [1,2,3,4,5,6,7,8,9,10,11,12]</span></span><br><span class="line">multi.flat(<span class="literal">Infinity</span>);       <span class="comment">// [1,2,3,4,5,6,7,8,9,10,11,12]</span></span><br></pre>
                  </td>
                </tr>
              </table>
            </figure>

            <h2 id="Array-flatMap"><a href="#Array-flatMap" class="headerlink" title="Array.flatMap()"></a>Array.flatMap()</h2>
            <figure class="highlight js">
              <table>
                <tr>
                  <td class="gutter">
                    <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                  </td>
                  <td class="code">
                    <pre><span class="line"><span class="keyword">let</span> array = [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>]</span><br><span class="line">array.map(<span class="function"><span class="params">x</span> =&gt;</span> [x, x * <span class="number">2</span>])</span><br></pre>
                  </td>
                </tr>
              </table>
            </figure>
            <p>变为：</p>
            <figure class="highlight js">
              <table>
                <tr>
                  <td class="gutter">
                    <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre>
                  </td>
                  <td class="code">
                    <pre><span class="line">[<span class="built_in">Array</span>(<span class="number">2</span>), <span class="built_in">Array</span>(<span class="number">2</span>), <span class="built_in">Array</span>(<span class="number">2</span>)]</span><br><span class="line"><span class="number">0</span>: (<span class="number">2</span>)[<span class="number">1</span>, <span class="number">2</span>]</span><br><span class="line"><span class="number">1</span>: (<span class="number">2</span>)[<span class="number">2</span>, <span class="number">4</span>]</span><br><span class="line"><span class="number">2</span>: (<span class="number">2</span>)[<span class="number">3</span>, <span class="number">6</span>]</span><br><span class="line"><span class="number">3</span>: (<span class="number">2</span>)[<span class="number">4</span>, <span class="number">8</span>]</span><br><span class="line"><span class="number">4</span>: (<span class="number">2</span>)[<span class="number">5</span>, <span class="number">10</span>]</span><br></pre>
                  </td>
                </tr>
              </table>
            </figure>
            <p>再次扁平化数组：</p>
            <figure class="highlight js">
              <table>
                <tr>
                  <td class="gutter">
                    <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                  </td>
                  <td class="code">
                    <pre><span class="line">array.flatMap(<span class="function"><span class="params">v</span> =&gt;</span> [v, v * <span class="number">2</span>])</span><br><span class="line">[<span class="number">1</span>, <span class="number">2</span>, <span class="number">2</span>, <span class="number">4</span>, <span class="number">3</span>, <span class="number">6</span>, <span class="number">4</span>, <span class="number">8</span>, <span class="number">5</span>, <span class="number">10</span>]</span><br></pre>
                  </td>
                </tr>
              </table>
            </figure>

            <h2 id="Object-fromEntries"><a href="#Object-fromEntries" class="headerlink" title="Object.fromEntries()"></a>Object.fromEntries()</h2>
            <p>将键值对列表转换为对象。</p>
            <figure class="highlight js">
              <table>
                <tr>
                  <td class="gutter">
                    <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre>
                  </td>
                  <td class="code">
                    <pre><span class="line"><span class="keyword">let</span> obj = &#123; <span class="attr">apple</span> : <span class="number">10</span>, <span class="attr">orange</span> : <span class="number">20</span>, <span class="attr">banana</span> : <span class="number">30</span> &#125;;</span><br><span class="line"><span class="keyword">let</span> entries = <span class="built_in">Object</span>.entries(obj);</span><br><span class="line">entries;</span><br><span class="line">(<span class="number">3</span>) [<span class="built_in">Array</span>(<span class="number">2</span>), <span class="built_in">Array</span>(<span class="number">2</span>), <span class="built_in">Array</span>(<span class="number">2</span>)]</span><br><span class="line"> <span class="number">0</span>: (<span class="number">2</span>) [<span class="string">&quot;apple&quot;</span>, <span class="number">10</span>]</span><br><span class="line"> <span class="number">1</span>: (<span class="number">2</span>) [<span class="string">&quot;orange&quot;</span>, <span class="number">20</span>]</span><br><span class="line"> <span class="number">2</span>: (<span class="number">2</span>) [<span class="string">&quot;banana&quot;</span>, <span class="number">30</span>]</span><br><span class="line"><span class="keyword">let</span> fromEntries = <span class="built_in">Object</span>.fromEntries(entries);</span><br><span class="line">&#123; <span class="attr">apple</span>: <span class="number">10</span>, <span class="attr">orange</span>: <span class="number">20</span>, <span class="attr">banana</span>: <span class="number">30</span> &#125;</span><br></pre>
                  </td>
                </tr>
              </table>
            </figure>

            <h2 id="String-trimStart-amp-String-trimEnd"><a href="#String-trimStart-amp-String-trimEnd" class="headerlink" title="String.trimStart() &amp; String.trimEnd()"></a>String.trimStart() &amp; String.trimEnd()</h2>
            <figure class="highlight js">
              <table>
                <tr>
                  <td class="gutter">
                    <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre>
                  </td>
                  <td class="code">
                    <pre><span class="line"><span class="keyword">let</span> greeting = <span class="string">&quot;     Space around     &quot;</span>;</span><br><span class="line">greeting.trimEnd();   <span class="comment">// &quot;     Space around&quot;;</span></span><br><span class="line">greeting.trimStart(); <span class="comment">// &quot;Space around     &quot;;</span></span><br></pre>
                  </td>
                </tr>
              </table>
            </figure>

            <h2 id="格式良好的JSON-stringify"><a href="#格式良好的JSON-stringify" class="headerlink" title="格式良好的JSON.stringify()"></a>格式良好的JSON.stringify()</h2>
            <p>此更新修复了字符<code>U + D800</code>到<code>U + DFFF</code>的处理，有时可以进入<code>JSON</code>字符串。这可能是一个问题，因为<code>JSON.stringify</code>可能会返回格式化为没有等效<code>UTF-8</code>字符的值的这些数字。但<code>JSON</code>格式需要<code>UTF-8</code>编码。</p>
            <p><code>JSON</code> 对象可用于解析<code>JSON</code> 格式（但也更多。）<code>JavaScript JSON</code> 对象也具有<code>stringify</code>和<code>parse</code>方法。</p>
            <p>该解析方法适用于一个结构良好的<code>JSON</code>字符串，如：</p>
            <figure class="highlight">
              <table>
                <tr>
                  <td class="gutter">
                    <pre><span class="line">1</span><br></pre>
                  </td>
                  <td class="code">
                    <pre><span class="line">&#x27;&#123; &quot;prop1&quot; : 1, &quot;prop2&quot; : 2 &#125;&#x27;; // A well-formed JSON format string</span><br></pre>
                  </td>
                </tr>
              </table>
            </figure>
            <p>请注意，创建具有正确<code>JSON</code>格式的字符串绝对需要使用围绕属性名称的双引号。缺少<code>...</code>或任何其他类型的引号将不会产生格式良好的<code>JSON</code>。</p>
            <figure class="highlight">
              <table>
                <tr>
                  <td class="gutter">
                    <pre><span class="line">1</span><br></pre>
                  </td>
                  <td class="code">
                    <pre><span class="line">&#x27;&#123; &quot;prop1&quot; : 1, &quot;meth&quot; : () =&gt; &#123;&#125;&#125;&#x27;; // Not JSON format string</span><br></pre>
                  </td>
                </tr>
              </table>
            </figure>
            <p><code>JSON</code> 字符串格式是不同的，从对象文本 ……它看起来几乎相同，但可以使用任何类型的周围属性名称的报价，还可以包括方法（JSON格式不允许的方法）：</p>
            <figure class="highlight js">
              <table>
                <tr>
                  <td class="gutter">
                    <pre><span class="line">1</span><br></pre>
                  </td>
                  <td class="code">
                    <pre><span class="line"><span class="keyword">let</span> object_literal = &#123; property：<span class="number">1</span>，meth：（）=&gt; &#123;&#125; &#125;;</span><br></pre>
                  </td>
                </tr>
              </table>
            </figure>
            <p>无论如何，一切似乎都很好。第一个示例看起来合规。但它们也是简单的例子，大部分时间都可以毫无障碍地工作！<br><strong>U + 2028和U + 2029字符</strong><br>这是捕获。<code>ES10</code>之前的<code>EcmaScript</code>实际上并不完全支持<code>JSON</code>格式。在ES10之前的时代，不接受未转义的行分隔符<code>U + 2028</code>和段落分隔符<code>U + 2029</code>字符：</p>
            <p><img src="" data-original="/images/es/0003.png" alt="0003"></p>
            <p>U + 2029是行分隔符。</p>
            <p><img src="" data-original="/images/es/0004.png" alt="0004"></p>
            <p>U + 2029是段落分隔符。有时它可能会潜入您的JSON格式字符串。</p>
            <p><strong>对于U + D800 - U + DFFF之间的所有字符也是如此</strong></p>
            <p>如果这些字符悄悄进入你的JSON格式的字符串（比如说来自数据库记录），你最终可能花费数小时试图弄清楚为什么程序的其余部分会产生解析错误。</p>
            <p>所以，如果你传递的<code>eval</code>一个字符串，像“<code>console.log(&#39;hello&#39;)</code>”这将执行<code>JavaScript</code>语句（试图通过字符串实际代码转换。）这也类似于如何<code>JSON.parse</code>将处理您的<code>JSON</code>字符串。</p>
            <h2 id="稳定的Array-prototype-sort"><a href="#稳定的Array-prototype-sort" class="headerlink" title="稳定的Array.prototype.sort()"></a>稳定的Array.prototype.sort()</h2>
            <p><code>V8</code>的先前实现对包含10个以上项的数组使用了<code>不稳定</code>的快速排序算法。</p>
            <p>一个稳定的排序算法是当两个具有相等键的对象在排序输出中以与未排序输入中出现的顺序相同的顺序出现时。</p>
            <p>但现在已经不是这样了。ES10提供稳定的阵列排序：</p>
            <figure class="highlight js">
              <table>
                <tr>
                  <td class="gutter">
                    <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre>
                  </td>
                  <td class="code">
                    <pre><span class="line"><span class="keyword">var</span> fruit = [</span><br><span class="line">    &#123; <span class="attr">name</span>: <span class="string">&quot;Apple&quot;</span>,      <span class="attr">count</span>: <span class="number">13</span>, &#125;,</span><br><span class="line">    &#123; <span class="attr">name</span>: <span class="string">&quot;Pear&quot;</span>,       <span class="attr">count</span>: <span class="number">12</span>, &#125;,</span><br><span class="line">    &#123; <span class="attr">name</span>: <span class="string">&quot;Banana&quot;</span>,     <span class="attr">count</span>: <span class="number">12</span>, &#125;,</span><br><span class="line">    &#123; <span class="attr">name</span>: <span class="string">&quot;Strawberry&quot;</span>, <span class="attr">count</span>: <span class="number">11</span>, &#125;,</span><br><span class="line">    &#123; <span class="attr">name</span>: <span class="string">&quot;Cherry&quot;</span>,     <span class="attr">count</span>: <span class="number">11</span>, &#125;,</span><br><span class="line">    &#123; <span class="attr">name</span>: <span class="string">&quot;Blackberry&quot;</span>, <span class="attr">count</span>: <span class="number">10</span>, &#125;,</span><br><span class="line">    &#123; <span class="attr">name</span>: <span class="string">&quot;Pineapple&quot;</span>,  <span class="attr">count</span>: <span class="number">10</span>, &#125;</span><br><span class="line">];</span><br><span class="line"><span class="comment">// Create our own sort criteria function:</span></span><br><span class="line"><span class="keyword">let</span> my_sort = <span class="function">(<span class="params">a, b</span>) =&gt;</span> a.count - b.count;</span><br><span class="line"><span class="comment">// Perform stable ES10 sort:</span></span><br><span class="line"><span class="keyword">let</span> sorted = fruit.sort(my_sort);</span><br><span class="line"><span class="built_in">console</span>.log(sorted);</span><br></pre>
                  </td>
                </tr>
              </table>
            </figure>
            <p>复控制台输出（项目以相反的顺序出现）：</p>
            <p><img src="" data-original="/images/es/0005.png" alt="0005"></p>
            <h2 id="New-Function-toString"><a href="#New-Function-toString" class="headerlink" title="New Function.toString()"></a>New Function.toString()</h2>
            <p>Funcitons是对象，每个对象都有个<code>.toString()</code>方法因为它最初存在于<code>Object.prototype.toString()</code>。所有的<code>objects</code>（包括functions）都继承至基于原型的类继承。这意味着我们已经有了<code>function.toString()</code>方法了。</p>
            <p>但是ES10进一步尝试标准化所有对象和内置函数的字符串表示。以下新案例：</p>
            <p><strong>Classic example</strong></p>
            <figure class="highlight js">
              <table>
                <tr>
                  <td class="gutter">
                    <pre><span class="line">1</span><br></pre>
                  </td>
                  <td class="code">
                    <pre><span class="line"><span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123; <span class="built_in">console</span>.log(<span class="string">&#x27;Hello there.&#x27;</span>); &#125;.toString();</span><br></pre>
                  </td>
                </tr>
              </table>
            </figure>
            <p>控制台输出（字符串格式的函数体:)</p>
            <figure class="highlight js">
              <table>
                <tr>
                  <td class="gutter">
                    <pre><span class="line">1</span><br></pre>
                  </td>
                  <td class="code">
                    <pre><span class="line">⇨ <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123; <span class="built_in">console</span>.log(<span class="string">&#x27;Hello there.&#x27;</span>); &#125;</span><br></pre>
                  </td>
                </tr>
              </table>
            </figure>
            <p>以下是其它案例：</p>
            <p><strong>直接来自函数名</strong></p>
            <figure class="highlight plain">
              <table>
                <tr>
                  <td class="gutter">
                    <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                  </td>
                  <td class="code">
                    <pre><span class="line">Number.parseInt.toString();</span><br><span class="line">⇨ function parseInt() &#123; [native code] &#125;</span><br></pre>
                  </td>
                </tr>
              </table>
            </figure>

            <p><strong>绑定上下文</strong></p>
            <figure class="highlight js">
              <table>
                <tr>
                  <td class="gutter">
                    <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                  </td>
                  <td class="code">
                    <pre><span class="line"><span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123; &#125;.bind(<span class="number">0</span>).toString();</span><br><span class="line">⇨ <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123; [native code] &#125;</span><br></pre>
                  </td>
                </tr>
              </table>
            </figure>

            <p><strong>内置可调用函数对象</strong></p>
            <figure class="highlight js">
              <table>
                <tr>
                  <td class="gutter">
                    <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                  </td>
                  <td class="code">
                    <pre><span class="line"><span class="built_in">Symbol</span>.toString();</span><br><span class="line">⇨ <span class="function"><span class="keyword">function</span> <span class="title">Symbol</span>(<span class="params"></span>) </span>&#123; [native code] &#125;</span><br></pre>
                  </td>
                </tr>
              </table>
            </figure>

            <p><strong>动态生成的函数</strong></p>
            <figure class="highlight js">
              <table>
                <tr>
                  <td class="gutter">
                    <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                  </td>
                  <td class="code">
                    <pre><span class="line"><span class="built_in">Function</span>().toString();</span><br><span class="line">⇨ <span class="function"><span class="keyword">function</span> <span class="title">anonymous</span>(<span class="params"></span>) </span>&#123;&#125;</span><br></pre>
                  </td>
                </tr>
              </table>
            </figure>

            <p><strong>动态生成的生成器 function</strong>*</p>
            <figure class="highlight js">
              <table>
                <tr>
                  <td class="gutter">
                    <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                  </td>
                  <td class="code">
                    <pre><span class="line"><span class="function"><span class="keyword">function</span>* (<span class="params"></span>) </span>&#123; &#125;.toString();</span><br><span class="line">⇨ <span class="function"><span class="keyword">function</span>* (<span class="params"></span>) </span>&#123; &#125;</span><br></pre>
                  </td>
                </tr>
              </table>
            </figure>

            <p><strong>prototype.toString</strong></p>
            <figure class="highlight js">
              <table>
                <tr>
                  <td class="gutter">
                    <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                  </td>
                  <td class="code">
                    <pre><span class="line"><span class="built_in">Function</span>.prototype.toString.call(&#123;&#125;);</span><br><span class="line">⇨ <span class="built_in">Function</span>.prototype.toString requires that <span class="string">&#x27;this&#x27;</span> be a <span class="built_in">Function</span><span class="string">&quot;</span></span><br></pre>
                  </td>
                </tr>
              </table>
            </figure>

            <h2 id="可选的Catch-Binding"><a href="#可选的Catch-Binding" class="headerlink" title="可选的Catch Binding"></a>可选的Catch Binding</h2>
            <p>在过去，<code>try / catch</code>语句中的<code>catch</code>子句需要一个变量。</p>
            <p><code>try / catch</code>语句帮助我们拦截在终端层面的错误：</p>
            <p>这是一个复习:</p>
            <figure class="highlight js">
              <table>
                <tr>
                  <td class="gutter">
                    <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre>
                  </td>
                  <td class="code">
                    <pre><span class="line"><span class="keyword">try</span> &#123;</span><br><span class="line">    <span class="comment">// Call a non-existing function undefined_Function</span></span><br><span class="line">    undefined_Function(<span class="string">&quot;I&#x27;m trying&quot;</span>);</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">catch</span>(error) &#123;</span><br><span class="line">    <span class="comment">// Display the error if statements inside try above fail</span></span><br><span class="line">    <span class="built_in">console</span>.log( error ); <span class="comment">// undefined_Function is undefined</span></span><br><span class="line">&#125;</span><br></pre>
                  </td>
                </tr>
              </table>
            </figure>

            <p>但在某些情况下，所需的<code>error</code>变量未被使用：</p>
            <figure class="highlight js">
              <table>
                <tr>
                  <td class="gutter">
                    <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre>
                  </td>
                  <td class="code">
                    <pre><span class="line"><span class="keyword">try</span> &#123;</span><br><span class="line">    <span class="built_in">JSON</span>.parse(text); <span class="comment">// &lt;--- this will fail with &quot;text not defined&quot;</span></span><br><span class="line">    <span class="keyword">return</span> <span class="literal">true</span>; <span class="xml">&lt;--- exit without error even if there is one</span></span><br><span class="line"><span class="xml">&#125;</span></span><br><span class="line">catch (redundant_sometmes) &lt;--- this makes error variable redundant</span><br><span class="line">&#123;</span><br><span class="line">    return false;</span><br><span class="line">&#125;</span><br></pre>
                  </td>
                </tr>
              </table>
            </figure>

            <p>编写此代码的人尝试通过强制为<code>true</code>退出<code>try</code>子句。但是……事实并非如此(正如<a href="https://link.juejin.im/?target=https://medium.com/@douglas.massolari"> Douglas Massolari.</a>所说)。</p>
            <figure class="highlight js">
              <table>
                <tr>
                  <td class="gutter">
                    <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre>
                  </td>
                  <td class="code">
                    <pre><span class="line">(<span class="function">() =&gt;</span> &#123;</span><br><span class="line">    <span class="keyword">try</span> &#123;</span><br><span class="line">        <span class="built_in">JSON</span>.parse(text)</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">true</span></span><br><span class="line">    &#125; <span class="keyword">catch</span>(err) &#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">false</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;)()</span><br><span class="line">=&gt; <span class="literal">false</span></span><br></pre>
                  </td>
                </tr>
              </table>
            </figure>

            <h3 id="在ES10中，Catch-Error-Binding是可选的"><a href="#在ES10中，Catch-Error-Binding是可选的" class="headerlink" title="在ES10中，Catch Error Binding是可选的"></a>在ES10中，Catch Error Binding是可选的</h3>
            <p>你现在可以跳过<code>error</code>变量：</p>
            <figure class="highlight js">
              <table>
                <tr>
                  <td class="gutter">
                    <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre>
                  </td>
                  <td class="code">
                    <pre><span class="line"><span class="keyword">try</span> &#123;</span><br><span class="line">    <span class="built_in">JSON</span>.parse(text);</span><br><span class="line">    <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">catch</span></span><br><span class="line">&#123;</span><br><span class="line">    <span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line">&#125;</span><br></pre>
                  </td>
                </tr>
              </table>
            </figure>

            <h2 id="Symbol-description"><a href="#Symbol-description" class="headerlink" title="Symbol.description"></a>Symbol.description</h2>
            <p><code>description</code> 是一个只读属性，返回<code>Symbol</code> 对象的可选描述。</p>
            <figure class="highlight js">
              <table>
                <tr>
                  <td class="gutter">
                    <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre>
                  </td>
                  <td class="code">
                    <pre><span class="line"><span class="keyword">let</span> mySymbol = <span class="string">&#x27;My Symbol&#x27;</span>;</span><br><span class="line"><span class="keyword">let</span> symObj = <span class="built_in">Symbol</span>(mySymbol);</span><br><span class="line">symObj; <span class="comment">// Symbol(My Symbol)</span></span><br><span class="line"><span class="built_in">String</span>(symObj) === <span class="string">`Symbol(<span class="subst">$&#123;mySymbol&#125;</span>)`</span>); <span class="comment">// true</span></span><br><span class="line">symObj.description; <span class="comment">// &quot;My Symbol&quot;</span></span><br></pre>
                  </td>
                </tr>
              </table>
            </figure>

            <h2 id="Hashbang-语法"><a href="#Hashbang-语法" class="headerlink" title="Hashbang 语法"></a>Hashbang 语法</h2>
            <p><code>shebang unix</code>用户会熟悉<code>AKA</code>。</p>
            <p>它指定一个解释器（什么将执行您的JavaScript文件？）</p>
            <p>ES10标准化了这一点。我不会详细介绍这个，因为这在技术上并不是一个真正的语言功能。但它基本上统一了JavaScript在服务器端的执行方式。</p>
            <figure class="highlight shell">
              <table>
                <tr>
                  <td class="gutter">
                    <pre><span class="line">1</span><br></pre>
                  </td>
                  <td class="code">
                    <pre><span class="line"><span class="meta">$</span><span class="bash"> ./index.js</span></span><br></pre>
                  </td>
                </tr>
              </table>
            </figure>

            <p>代替：</p>
            <figure class="highlight shell">
              <table>
                <tr>
                  <td class="gutter">
                    <pre><span class="line">1</span><br></pre>
                  </td>
                  <td class="code">
                    <pre><span class="line"><span class="meta">$</span><span class="bash"> node index.js</span></span><br></pre>
                  </td>
                </tr>
              </table>
            </figure>

            <blockquote>
              <p>在类Unix操作系统下。</p>
            </blockquote>
            <h2 id="ES10-Classes-private-static-amp-public-members"><a href="#ES10-Classes-private-static-amp-public-members" class="headerlink" title="ES10 Classes: private, static &amp; public members"></a>ES10 Classes: private, static &amp; public members</h2>
            <p><strong>新的语法字符#（hash tag）现在直接在类主体作用域以及<code>constructor</code>和类方法里被用来定义<code>variables</code>， <code>functions</code>，<code>getters</code>和<code>setters</code></strong></p>
            <p>这是一个相当无意义的示例，仅关注新语法：</p>
            <figure class="highlight js">
              <table>
                <tr>
                  <td class="gutter">
                    <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre>
                  </td>
                  <td class="code">
                    <pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Raven</span> <span class="keyword">extends</span> <span class="title">Bird</span> </span>&#123;</span><br><span class="line">    #state = &#123; <span class="attr">eggs</span>: <span class="number">10</span>&#125;;</span><br><span class="line">    <span class="comment">// getter</span></span><br><span class="line">    get #<span class="function"><span class="title">eggs</span>(<span class="params"></span>)</span> &#123; </span><br><span class="line">        <span class="keyword">return</span> state.eggs;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">// setter</span></span><br><span class="line">    set #<span class="function"><span class="title">eggs</span>(<span class="params">value</span>)</span> &#123;</span><br><span class="line">        <span class="built_in">this</span>.#state.eggs = value;</span><br><span class="line">    &#125;</span><br><span class="line">    #<span class="function"><span class="title">lay</span>(<span class="params"></span>)</span> &#123;</span><br><span class="line">        <span class="built_in">this</span>.#eggs++;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="function"><span class="title">constructor</span>(<span class="params"></span>)</span> &#123;</span><br><span class="line">        <span class="built_in">super</span>();</span><br><span class="line">        <span class="built_in">this</span>.#lay.bind(<span class="built_in">this</span>);</span><br><span class="line">    &#125;</span><br><span class="line">    #<span class="function"><span class="title">render</span>(<span class="params"></span>)</span> &#123;</span><br><span class="line">        <span class="comment">/* paint UI */</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre>
                  </td>
                </tr>
              </table>
            </figure>

            <p><img src="" data-original="/images/es/0006.png" alt="0006"></p>
            <p><img src="" data-original="/images/es/0007.png" alt="0007"></p>
            <h2 id="总结与反馈"><a href="#总结与反馈" class="headerlink" title="总结与反馈"></a>总结与反馈</h2>
            <p>ES10是一套尚未有机会在生产环境中进行全面探索的新功能。如果您有任何更正，建议或任何其他反馈，请告诉我们。</p>
            <p>我经常写一个教程，因为我想自己学习一些科目。这是其中一次,有其他人已经编译的资源的帮助：</p>
            <p>感谢Sergey Podgornyy写了这篇<a href="https://link.juejin.im/?target=https://blog.larapulse.com/es-2015/ecmascript-10">ES10教程</a>。 感谢 Selvaganesh写了这篇<a href="https://link.juejin.im/?target=https://medium.com/@selvaganesh93/javascript-whats-new-in-ecmascript-2019-es2019-es10-35210c6e7f4b">ES10教程</a>。</p>
            <h1 id="参考"><a href="#参考" class="headerlink" title="参考"></a>参考</h1>
            <p><a target="_blank" rel="noopener" href="http://www.ecma-international.org/ecma-262/10.0/index.html">ecma-262-10.0</a><br><a target="_blank" rel="noopener" href="https://mp.weixin.qq.com/s/b3oHxsidGHtnv0U1lYashg">【译】ES10功能完全指南</a><br>(<a target="_blank" rel="noopener" href="https://juejin.im/post/5c7c8e125188256365101c34">https://juejin.im/post/5c7c8e125188256365101c34</a>)</p>

          </div>





          <footer class="post-footer">
            <div class="post-tags">
              <a href="/tags/JavaScript/" rel="tag"># JavaScript</a>
              <a href="/tags/Ecma/" rel="tag"># Ecma</a>
              <a href="/tags/ECMAScript/" rel="tag"># ECMAScript</a>
              <a href="/tags/ES10/" rel="tag"># ES10</a>
              <a href="/tags/ES2019/" rel="tag"># ES2019</a>
              <a href="/tags/ECMAScript-2019/" rel="tag"># ECMAScript 2019</a>
            </div>



            <div class="post-nav">
              <div class="post-nav-item">
                <a href="/blob/2019-04-17-new-features-of-javsscript-es9-&-es2018/" rel="prev" title="JavsScript ES9&ES2018的新特性">
                  <i class="fa fa-chevron-left"></i> JavsScript ES9&ES2018的新特性
                </a>
              </div>
              <div class="post-nav-item">
                <a href="/blob/2019-04-18-400-problems-with-nginx-configuration-reverse-proxy-or-jump/" rel="next" title="nginx配置反向代理或跳转出现400问题">
                  nginx配置反向代理或跳转出现400问题 <i class="fa fa-chevron-right"></i>
                </a>
              </div>
            </div>
          </footer>
        </article>
      </div>







      <script>
        window.addEventListener('tabs:register', () => {
          let {
            activeClass
          } = CONFIG.comments;
          if (CONFIG.comments.storage) {
            activeClass = localStorage.getItem('comments_active') || activeClass;
          }
          if (activeClass) {
            const activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
            if (activeTab) {
              activeTab.click();
            }
          }
        });
        if (CONFIG.comments.storage) {
          window.addEventListener('tabs:click', event => {
            if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
            const commentClass = event.target.classList[1];
            localStorage.setItem('comments_active', commentClass);
          });
        }
      </script>
    </div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


      <div class="copyright">
        &copy;
        <span itemprop="copyrightYear">2021</span>
        <span class="with-love">
          <i class="fa fa-heart"></i>
        </span>
        <span class="author" itemprop="copyrightHolder">holidaypenguin</span>
      </div>
      <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/mist/" class="theme-link" rel="noopener" target="_blank">NexT.Mist</a> 强力驱动
      </div>

    </div>
  </footer>


  <script size="300" alpha="0.1" zIndex="-1" src="https://cdn.jsdelivr.net/npm/ribbon.js@1.0.2/dist/ribbon.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/animejs@3.2.1/lib/anime.min.js"></script>
  <script src="/js/love.js"></script>

  <script src="/js/development.js"></script>
  <script src="/js/utils.js"></script>
  <script src="/js/motion.js"></script>
  <script src="/js/schemes/muse.js"></script>
  <script src="/js/next-boot.js"></script>


  <script src="/js/local-search.js"></script>









  <script>
    (function() {
      function leancloudSelector(url) {
        url = encodeURI(url);
        return document.getElementById(url).querySelector('.leancloud-visitors-count');
      }

      function addCount(Counter) {
        const visitors = document.querySelector('.leancloud_visitors');
        const url = decodeURI(visitors.id);
        const title = visitors.dataset.flagTitle;

        Counter('get', '/classes/Counter?where=' + encodeURIComponent(JSON.stringify({
            url
          })))
          .then(response => response.json())
          .then(({
            results
          }) => {
            if (results.length > 0) {
              const counter = results[0];
              leancloudSelector(url).innerText = counter.time + 1;
              Counter('put', '/classes/Counter/' + counter.objectId, {
                  time: {
                    '__op': 'Increment',
                    'amount': 1
                  }
                })
                .catch(error => {
                  console.error('Failed to save visitor count', error);
                });
            } else {
              Counter('post', '/classes/Counter', {
                  title,
                  url,
                  time: 1
                })
                .then(response => response.json())
                .then(() => {
                  leancloudSelector(url).innerText = 1;
                })
                .catch(error => {
                  console.error('Failed to create', error);
                });
            }
          })
          .catch(error => {
            console.error('LeanCloud Counter Error', error);
          });
      }

      function showTime(Counter) {
        const visitors = document.querySelectorAll('.leancloud_visitors');
        const entries = [...visitors].map(element => {
          return decodeURI(element.id);
        });

        Counter('get', '/classes/Counter?where=' + encodeURIComponent(JSON.stringify({
            url: {
              '$in': entries
            }
          })))
          .then(response => response.json())
          .then(({
            results
          }) => {
            for (let url of entries) {
              const target = results.find(item => item.url === url);
              leancloudSelector(url).innerText = target ? target.time : 0;
            }
          })
          .catch(error => {
            console.error('LeanCloud Counter Error', error);
          });
      }

      const {
        app_id,
        app_key,
        server_url
      } = {
        "enable": true,
        "app_id": "povuqNsSqFodlakVIwtEX5kb-gzGzoHsz",
        "app_key": "zXD40RDtDB3DMtpC89k0AK7g",
        "server_url": null,
        "security": false
      };

      function fetchData(api_server) {
        const Counter = (method, url, data) => {
          return fetch(`${api_server}/1.1${url}`, {
            method,
            headers: {
              'X-LC-Id': app_id,
              'X-LC-Key': app_key,
              'Content-Type': 'application/json',
            },
            body: JSON.stringify(data)
          });
        };
        if (CONFIG.page.isPost) {
          if (CONFIG.hostname !== location.hostname) return;
          addCount(Counter);
        } else if (document.querySelectorAll('.post-title-link').length >= 1) {
          showTime(Counter);
        }
      }

      const api_server = app_id.slice(-9) === '-MdYXbMMI' ? `https://${app_id.slice(0, 8).toLowerCase()}.api.lncldglobal.com` : server_url;

      if (api_server) {
        fetchData(api_server);
      } else {
        fetch('https://app-router.leancloud.cn/2/route?appId=' + app_id)
          .then(response => response.json())
          .then(({
            api_server
          }) => {
            fetchData('https://' + api_server);
          });
      }
    })();
  </script>



<script>
            window.imageLazyLoadSetting = {
                isSPA: false,
                preloadRatio: 1,
                processImages: null,
            };
        </script><script>window.addEventListener("load",function(){var t=/\.(gif|jpg|jpeg|tiff|png)$/i,r=/^data:image\/[a-z]+;base64,/;Array.prototype.slice.call(document.querySelectorAll("img[data-original]")).forEach(function(a){var e=a.parentNode;"A"===e.tagName&&(e.href.match(t)||e.href.match(r))&&(e.href=a.dataset.original)})});</script><script>!function(n){n.imageLazyLoadSetting.processImages=o;var e=n.imageLazyLoadSetting.isSPA,i=n.imageLazyLoadSetting.preloadRatio||1,r=Array.prototype.slice.call(document.querySelectorAll("img[data-original]"));function o(){e&&(r=Array.prototype.slice.call(document.querySelectorAll("img[data-original]")));for(var t,a=0;a<r.length;a++)0<=(t=(t=r[a]).getBoundingClientRect()).bottom&&0<=t.left&&t.top<=(n.innerHeight*i||document.documentElement.clientHeight*i)&&function(){var t,e,n,i,o=r[a];t=o,e=function(){r=r.filter(function(t){return o!==t})},n=new Image,i=t.getAttribute("data-original"),n.onload=function(){t.src=i,e&&e()},t.src!==i&&(n.src=i)}()}o(),n.addEventListener("scroll",function(){var t,e;t=o,e=n,clearTimeout(t.tId),t.tId=setTimeout(function(){t.call(e)},500)})}(this);</script></body>

</html>